1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module adw.Carousel; 26 27 private import adw.SpringParams; 28 private import adw.SwipeableIF; 29 private import adw.SwipeableT; 30 private import adw.c.functions; 31 public import adw.c.types; 32 private import glib.ConstructionException; 33 private import gobject.ObjectG; 34 private import gobject.Signals; 35 private import gtk.AccessibleIF; 36 private import gtk.AccessibleT; 37 private import gtk.BuildableIF; 38 private import gtk.BuildableT; 39 private import gtk.ConstraintTargetIF; 40 private import gtk.ConstraintTargetT; 41 private import gtk.OrientableIF; 42 private import gtk.OrientableT; 43 private import gtk.Widget; 44 private import std.algorithm; 45 46 47 /** 48 * A paginated scrolling widget. 49 * 50 * <picture> 51 * <source srcset="carousel-dark.png" media="(prefers-color-scheme: dark)"> 52 * <img src="carousel.png" alt="carousel"> 53 * </picture> 54 * 55 * The `AdwCarousel` widget can be used to display a set of pages with 56 * swipe-based navigation between them. 57 * 58 * [class@CarouselIndicatorDots] and [class@CarouselIndicatorLines] can be used 59 * to provide page indicators for `AdwCarousel`. 60 * 61 * ## CSS nodes 62 * 63 * `AdwCarousel` has a single CSS node with name `carousel`. 64 * 65 * Since: 1.0 66 */ 67 public class Carousel : Widget, SwipeableIF, OrientableIF 68 { 69 /** the main Gtk struct */ 70 protected AdwCarousel* adwCarousel; 71 72 /** Get the main Gtk struct */ 73 public AdwCarousel* getCarouselStruct(bool transferOwnership = false) 74 { 75 if (transferOwnership) 76 ownedRef = false; 77 return adwCarousel; 78 } 79 80 /** the main Gtk struct as a void* */ 81 protected override void* getStruct() 82 { 83 return cast(void*)adwCarousel; 84 } 85 86 /** 87 * Sets our main struct and passes it to the parent class. 88 */ 89 public this (AdwCarousel* adwCarousel, bool ownedRef = false) 90 { 91 this.adwCarousel = adwCarousel; 92 super(cast(GtkWidget*)adwCarousel, ownedRef); 93 } 94 95 // add the Swipeable capabilities 96 mixin SwipeableT!(AdwCarousel); 97 98 // add the Orientable capabilities 99 mixin OrientableT!(AdwCarousel); 100 101 102 /** */ 103 public static GType getType() 104 { 105 return adw_carousel_get_type(); 106 } 107 108 /** 109 * Creates a new `AdwCarousel`. 110 * 111 * Returns: the newly created `AdwCarousel` 112 * 113 * Since: 1.0 114 * 115 * Throws: ConstructionException GTK+ fails to create the object. 116 */ 117 public this() 118 { 119 auto __p = adw_carousel_new(); 120 121 if(__p is null) 122 { 123 throw new ConstructionException("null returned by new"); 124 } 125 126 this(cast(AdwCarousel*) __p); 127 } 128 129 /** 130 * Appends @child to @self. 131 * 132 * Params: 133 * child = a widget to add 134 * 135 * Since: 1.0 136 */ 137 public void append(Widget child) 138 { 139 adw_carousel_append(adwCarousel, (child is null) ? null : child.getWidgetStruct()); 140 } 141 142 /** 143 * Gets whether to allow swiping for more than one page at a time. 144 * 145 * Returns: `TRUE` if long swipes are allowed 146 * 147 * Since: 1.0 148 */ 149 public bool getAllowLongSwipes() 150 { 151 return adw_carousel_get_allow_long_swipes(adwCarousel) != 0; 152 } 153 154 /** 155 * Sets whether @self can be dragged with mouse pointer. 156 * 157 * Returns: whether @self can be dragged with mouse pointer 158 * 159 * Since: 1.0 160 */ 161 public bool getAllowMouseDrag() 162 { 163 return adw_carousel_get_allow_mouse_drag(adwCarousel) != 0; 164 } 165 166 /** 167 * Gets whether @self will respond to scroll wheel events. 168 * 169 * Returns: `TRUE` if @self will respond to scroll wheel events 170 * 171 * Since: 1.0 172 */ 173 public bool getAllowScrollWheel() 174 { 175 return adw_carousel_get_allow_scroll_wheel(adwCarousel) != 0; 176 } 177 178 /** 179 * Gets whether @self can be navigated. 180 * 181 * Returns: whether @self can be navigated 182 * 183 * Since: 1.0 184 */ 185 public bool getInteractive() 186 { 187 return adw_carousel_get_interactive(adwCarousel) != 0; 188 } 189 190 /** 191 * Gets the number of pages in @self. 192 * 193 * Returns: the number of pages in @self 194 * 195 * Since: 1.0 196 */ 197 public uint getNPages() 198 { 199 return adw_carousel_get_n_pages(adwCarousel); 200 } 201 202 /** 203 * Gets the page at position @n. 204 * 205 * Params: 206 * n = index of the page 207 * 208 * Returns: the page 209 * 210 * Since: 1.0 211 */ 212 public Widget getNthPage(uint n) 213 { 214 auto __p = adw_carousel_get_nth_page(adwCarousel, n); 215 216 if(__p is null) 217 { 218 return null; 219 } 220 221 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) __p); 222 } 223 224 /** 225 * Gets current scroll position in @self. 226 * 227 * It's unitless, 1 matches 1 page. 228 * 229 * Returns: the scroll position 230 * 231 * Since: 1.0 232 */ 233 public double getPosition() 234 { 235 return adw_carousel_get_position(adwCarousel); 236 } 237 238 /** 239 * Gets duration of the animation used when adding or removing pages. 240 * 241 * Returns: the duration 242 * 243 * Since: 1.0 244 */ 245 public uint getRevealDuration() 246 { 247 return adw_carousel_get_reveal_duration(adwCarousel); 248 } 249 250 /** 251 * Gets the scroll animation spring parameters for @self. 252 * 253 * Returns: the animation parameters 254 * 255 * Since: 1.0 256 */ 257 public SpringParams getScrollParams() 258 { 259 auto __p = adw_carousel_get_scroll_params(adwCarousel); 260 261 if(__p is null) 262 { 263 return null; 264 } 265 266 return ObjectG.getDObject!(SpringParams)(cast(AdwSpringParams*) __p, true); 267 } 268 269 /** 270 * Gets spacing between pages in pixels. 271 * 272 * Returns: spacing between pages 273 * 274 * Since: 1.0 275 */ 276 public uint getSpacing() 277 { 278 return adw_carousel_get_spacing(adwCarousel); 279 } 280 281 /** 282 * Inserts @child into @self at position @position. 283 * 284 * If position is -1, or larger than the number of pages, 285 * @child will be appended to the end. 286 * 287 * Params: 288 * child = a widget to add 289 * position = the position to insert @child at 290 * 291 * Since: 1.0 292 */ 293 public void insert(Widget child, int position) 294 { 295 adw_carousel_insert(adwCarousel, (child is null) ? null : child.getWidgetStruct(), position); 296 } 297 298 /** 299 * Prepends @child to @self. 300 * 301 * Params: 302 * child = a widget to add 303 * 304 * Since: 1.0 305 */ 306 public void prepend(Widget child) 307 { 308 adw_carousel_prepend(adwCarousel, (child is null) ? null : child.getWidgetStruct()); 309 } 310 311 /** 312 * Removes @child from @self. 313 * 314 * Params: 315 * child = a widget to remove 316 * 317 * Since: 1.0 318 */ 319 public void remove(Widget child) 320 { 321 adw_carousel_remove(adwCarousel, (child is null) ? null : child.getWidgetStruct()); 322 } 323 324 /** 325 * Moves @child into position @position. 326 * 327 * If position is -1, or larger than the number of pages, @child will be moved 328 * at the end. 329 * 330 * Params: 331 * child = a widget to add 332 * position = the position to move @child to 333 * 334 * Since: 1.0 335 */ 336 public void reorder(Widget child, int position) 337 { 338 adw_carousel_reorder(adwCarousel, (child is null) ? null : child.getWidgetStruct(), position); 339 } 340 341 /** 342 * Scrolls to @widget. 343 * 344 * If @animate is `TRUE`, the transition will be animated. 345 * 346 * Params: 347 * widget = a child of @self 348 * animate = whether to animate the transition 349 * 350 * Since: 1.0 351 */ 352 public void scrollTo(Widget widget, bool animate) 353 { 354 adw_carousel_scroll_to(adwCarousel, (widget is null) ? null : widget.getWidgetStruct(), animate); 355 } 356 357 /** 358 * Sets whether to allow swiping for more than one page at a time. 359 * 360 * Params: 361 * allowLongSwipes = whether to allow long swipes 362 * 363 * Since: 1.0 364 */ 365 public void setAllowLongSwipes(bool allowLongSwipes) 366 { 367 adw_carousel_set_allow_long_swipes(adwCarousel, allowLongSwipes); 368 } 369 370 /** 371 * Sets whether @self can be dragged with mouse pointer. 372 * 373 * Params: 374 * allowMouseDrag = whether @self can be dragged with mouse pointer 375 * 376 * Since: 1.0 377 */ 378 public void setAllowMouseDrag(bool allowMouseDrag) 379 { 380 adw_carousel_set_allow_mouse_drag(adwCarousel, allowMouseDrag); 381 } 382 383 /** 384 * Sets whether @self will respond to scroll wheel events. 385 * 386 * Params: 387 * allowScrollWheel = whether @self will respond to scroll wheel events 388 * 389 * Since: 1.0 390 */ 391 public void setAllowScrollWheel(bool allowScrollWheel) 392 { 393 adw_carousel_set_allow_scroll_wheel(adwCarousel, allowScrollWheel); 394 } 395 396 /** 397 * Sets whether @self can be navigated. 398 * 399 * Params: 400 * interactive = whether @self can be navigated 401 * 402 * Since: 1.0 403 */ 404 public void setInteractive(bool interactive) 405 { 406 adw_carousel_set_interactive(adwCarousel, interactive); 407 } 408 409 /** 410 * Sets duration of the animation used when adding or removing pages. 411 * 412 * Params: 413 * revealDuration = the new reveal duration value 414 * 415 * Since: 1.0 416 */ 417 public void setRevealDuration(uint revealDuration) 418 { 419 adw_carousel_set_reveal_duration(adwCarousel, revealDuration); 420 } 421 422 /** 423 * Sets the scroll animation spring parameters for @self. 424 * 425 * Params: 426 * params = the new parameters 427 * 428 * Since: 1.0 429 */ 430 public void setScrollParams(SpringParams params) 431 { 432 adw_carousel_set_scroll_params(adwCarousel, (params is null) ? null : params.getSpringParamsStruct()); 433 } 434 435 /** 436 * Sets spacing between pages in pixels. 437 * 438 * Params: 439 * spacing = the new spacing value 440 * 441 * Since: 1.0 442 */ 443 public void setSpacing(uint spacing) 444 { 445 adw_carousel_set_spacing(adwCarousel, spacing); 446 } 447 448 /** 449 * This signal is emitted after a page has been changed. 450 * 451 * It can be used to implement "infinite scrolling" by amending the pages 452 * after every scroll. 453 * 454 * Params: 455 * index = current page 456 * 457 * Since: 1.0 458 */ 459 gulong addOnPageChanged(void delegate(uint, Carousel) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 460 { 461 return Signals.connect(this, "page-changed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 462 } 463 }